package com.senon.mvpretrofitrx.mvp.api;

import com.senon.mvpretrofitrx.mvp.base.BaseApi;
import com.senon.mvpretrofitrx.mvp.test.JuheService;

/**
 *
 */

public class Api {

    private String baseUrl = "http://www.kuaidi100.com/";
//    private String baseUrl = "http://hbhz.sesdf.org/api/";
//    http://www.kuaidi100.com/query?type=快递公司代号&postid=快递单号

    private volatile static ApiService apiService;
    private volatile static JuheService juheService;

    public static ApiService getApiService() {
        if (apiService == null) {
            synchronized (Api.class) {
                if (apiService == null) {
                    new Api();
                }
            }
        }
        return apiService;
    }

    public static JuheService getJuheService() {
        if (juheService == null) {
            synchronized (Api.class) {
                if (juheService == null) {
                    getJuheAPi();
                }
            }
        }
        return juheService;
    }

    private Api() {
        BaseApi baseApi = new BaseApi();
        apiService = baseApi.getRetrofit(baseUrl).create(ApiService.class);
    }

    /**
     * 测试模拟获取聚合数据
     */
    public static void getJuheAPi() {
        BaseApi baseApi = new BaseApi();
        juheService = baseApi.getRetrofit(JuheService.baseUrl).create(JuheService.class);
    }
}
